package com.zm.exam.springbootexam.entry;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.sql.Timestamp;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("user")
public class User {
    @TableId(value = "id",type = IdType.AUTO)
    private Integer id;

    @NotBlank(message = "账号不能为空！")
    @Length(min = 2,max = 20,message = "账号的长度必须是2~20个字符!")
    private String name;

    @NotBlank(message = "密码不能为空！")
    @Length(min = 4,max = 16,message = "密码的长度必须是4~16个字符!")
    @Pattern(regexp = "[\\w&@\\*]{4,16}",message = "密码必须由数字字母特殊字符构成！")
    private String pwd;

    @Pattern(regexp = "1[0-9]{10}",message = "手机号码必须是1开头的11位数字！")
    private String phone;

    @Email
    @NotBlank
    private String email;

    private String head;

    @TableField("create_time")
    private Timestamp createTime;

    private String role;

}
